<%@page import="com.remist.common.Constant"%>
<%@page import="com.remist.model.*"%>
<%@page import="java.util.*"%>
<%@page import="com.remist.service.*"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<html><head>
<%@include file="header.jsp"%>
 
<%
	String[] pageActions = new String[]{
		"newArrivals",
		"whatsOnSale",
		"personalization",
		"ankletJewelryBeadOnline",
		"bangleJewelrySilverWood",
		"braceletJewelry",
		"chainJewelry",
		"earringJewelryOnline",
		"pendantNecklaceJewelry",
		"ringOnlineJewelry",
		"toeRingOnlineJewelry",
		"jewelrySet",
		"hawaiianAccessories"
		};
 
 /*
Chains','Looking to ad
Earrings','Remist offe
Hawaiian Pendants & Ne
Rings','Hawaiian Rings
Jewelry Sets','',0,'')
'Toe Rings','Toe Rings
'Hawaiian Accessories'
*/
	String[] catalogs = new String[]{
		"New Arrivals",
		"SALE",
		"Personalized Jewelry",
		"Anklets",
		"Bangles",
		"Hawaiian Bracelets",
		"Chains",
		"Earrings",
		"Hawaiian Pendants & Necklaces",
		"Rings",
		"Jewelry Sets",
		"Toe Rings",
		"Hawaiian Accessories"
		};

 
 String pageName = com.opensymphony.xwork2.ActionContext.getContext().getName();
 
 
 String catalogsName = "";
 
 if ( pageName != null && !"".equals(pageName)){
		for( int i = 0 ; i < pageActions.length ; i++ ){
			if ( pageName.equalsIgnoreCase( pageActions[ i ] ) ) {
				catalogsName = catalogs[i];
				break;
			}
		}
 }
System.out.println( catalogsName );
ImagesService imagesService = (ImagesService) Constant.getSpringCtx().getBean("imagesService");
com.remist.service.ProductTypeService pt =(com.remist.service.ProductTypeService) Constant.getSpringCtx().getBean("productTypeService");
com.remist.service.ProductService ps =(com.remist.service.ProductService) Constant.getSpringCtx().getBean("productService");
ProductType beanType = new com.remist.model.ProductType();
if ( catalogsName .equals("")){
	 String typeId=request.getParameter("productTypeId");
	 if ( typeId != null ) {
	 	beanType.setId( Integer.parseInt(typeId));
	 	beanType = pt.getProductTypeByKey( beanType );
	 }
} else {
	beanType.setName( catalogsName );
	beanType = pt.getProductTypeByName( beanType );
}
LinkedList< ProductType > allParentTypes = pt.listAllParents( beanType );
allParentTypes.add( beanType );
List<ProductType> subChilds = pt.listChilds(beanType);
java.util.List<Product> products =  ps.getProductByType( beanType );

%>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<title></title>
		<meta name="keywords" content="hawaiian anklets, fimo jewelry, hawaiian silver jewelry, hawaiian gold jewelry">
		<meta name="description" content="">
		<meta name="ROBOTS" content="NOODP, NOYDIR ">
		<style type="text/css">
			<!--
			body 
			{
				margin-left: 0px;
				margin-top: 0px;
				margin-right: 0px;
				margin-bottom: 0px;
				background-image: url(images/bg.jpg);
			}
			-->
		</style>
		<link href="css/yenki.css" rel="stylesheet" type="text/css">
		<%--
		<script language="javascript" src="images/popupCentralwindowVHS.js"></script>
		 --%>

	</head>
	<body>
		<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" height="100%" width="950">
			<%@ include file="top.jsp"%>	
<%-- end --%>			
			
			<tr>
				<td valign="top">
					<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
					<tr>
						<td align="center">
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<%-- left area --%>
							<%@ include file="mainLeft.jsp"%>
							<%-- left area end --%>
								<td width="1%">&nbsp;</td>
								<td height="100%" valign="top">
									<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
									<tr>
										<td height="10"></td>
									</tr>
									<tr>
										<td bgcolor="3E80CB" height="10">
											<table border="0" cellpadding="0" cellspacing="0" width="100%">
											<tr>
												<td width="2%"><img src="images/new_arrivals_left.jpg"></td>
												<td class="title" width="96%"><%=beanType.getName() %></td>
												<td width="2%"><img src="images/new_arrivals_right.gif"></td>
											</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td class="box1" valign="top">
											<table align="center" cellpadding="3" cellspacing="1" width="98%">
												<tr>
													<td colspan="3" height="10"></td>
												</tr>
												<tr>
							
							<!-- navita area  begin-->						
													<td class="sitetext" colspan="3">
														<a href="<%=contextPath %>/web/index.action" class="links1">Home</a>&nbsp;
														<%for( int k=0; k< allParentTypes.size();k++ ) { %>
														<img src="images/arrow_blue.gif" height="5" width="5">
														<a href="<%=contextPath %>/web/subProductTypeDetail.action?productTypeId=<%=allParentTypes.get(k).getId() %>" class="links1">
														 <%=allParentTypes.get(k).getName() %>
														</a>
														<%} %>
													</td>
							<!-- navita area  end -->
												</tr>
												<tr>
													<td colspan="3" height="10"></td>
						    					</tr>
												<tr>
													<td colspan="3" class="sitetext" valign="top">
														<table align="center" border="0" cellpadding="3" cellspacing="1" width="98%">
															<tr>
																<td class="sitetext" valign="top">
																	<p class="MsoHeader" style="MARGIN: 0in 0in 0pt">
																		<font face="Arial">
																			<span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt">
																				<%=beanType.getDescription() %>
																			</span>
																		</font>
																	</p>
																</td>
															</tr>
														</table>
													</td>
												</tr>
						    					<tr>
													<td colspan="3" height="10"></td>
						   						</tr>
												<!-- product Type begin-->
												<%
												int count = subChilds.size()%2 == 0? subChilds.size():subChilds.size()+1;
												for ( int k=0;k< count;k=k+2){
												%>
						   						<tr>
						   							<% ProductType pe = subChilds.get(k);%>
						   							<td valign="top" width="49%">
														<table border="0" cellpadding="3" cellspacing="1" width="100%">
															<tr>
									  							<td class="blacktext" style="border-bottom: 1px dashed rgb(204, 204, 204);"><%=pe.getName() %></td>
															</tr>
															<tr>
									  							<td class="sitetext" valign="top"><p align="justify"> <img src="images/subcat_S4580086946.jpg" alt="" class="floatLeft" border="0"> <%=pe.getDescription() %> <br>
									  							<a href="<%=contextPath %>/web/subProductTypeDetail.action?productTypeId=<%=beanType.getId() %>"><img src="images/more.gif" border="0"></a></p></td>
															</tr>
														</table>
													</td>
													
													<td width="2%">&nbsp;</td>
													<%
													pe = new ProductType();
													pe.setName("");
													pe.setDescription("");
													if ( (k+1)< subChilds.size() ){
														pe = subChilds.get(k+1);
													%>
													<td valign="top" width="49%">
														<table border="0" cellpadding="3" cellspacing="1" width="100%">
															<tr>
									  							<td class="blacktext" style="border-bottom: 1px dashed rgb(204, 204, 204);"><%=pe.getName() %></td>
															</tr>
															<tr>
									  							<td class="sitetext" valign="top">
									  								<p align="justify">
									  									<img src="images/subcat_S8707684736.jpg" alt="" class="floatLeft" border="0"><%=pe.getDescription() %><br>
									  									<a href="<%=contextPath %>/web/subProductTypeDetail.action?productTypeId=<%=pe.getId() %>"><img src="images/more.gif" border="0"></a>
									  								</p>
									  							</td>
															</tr>
														</table>
													</td>
													<% }%>
													</tr>
													
													
													<tr>
														<td colspan="3">&nbsp;</td>
													</tr>
													<%} %>
                                                    <!-- product Type end-->
                                                    
                                                    
                                                    													 							
													<tr>
														<td colspan="3" height="10"></td>
													</tr>
													<tr>
														<td colspan="3">
															<link href="images/yenki.css" rel="stylesheet" type="text/css">
															<table align="center" border="0" cellpadding="3" cellspacing="1" width="100%">
																<tr bgcolor="F2FAEB">
																	<td class="headers" colspan="3">&nbsp;Products&nbsp;<img src="images/arrow.gif"></td>
																</tr>
																<!-- product List begin -->
																<%
																count = products.size()%2 == 0? products.size():products.size()+1;
																for ( int k=0;k< count;k=k+2){ %>
																<tr>
																<% Product pdt = products.get(k);%>
																	<td height="100%" valign="top" width="49%">
					   													<table border="0" cellpadding="3" cellspacing="1" height="100%" width="100%">
									  										<tr>
									  											 <%
																					 ImageMapBean image = new ImageMapBean();
																					 image.setReferenceId(pdt.getId());
																					 List<ImageMapBean> images =imagesService.getImagesByReferenceId(image);
																					 image = (images.size()==0?null:images.get(0));
										 										%>
																				<td align="center"><img src="<%=contextPath %>/<%if ( image != null ) out.println( image.getImageUrl()); %>"  alt=""  height="90"  width="120"></td>
									  										</tr>
									  										<tr>
																				<td valign="bottom">
																					<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
																						<tr>
																							<td colspan="3" class="headers" align="center" height="30" valign="top">
																								<% if ( pdt.getDescription().length()>10) out.println( pdt.getDescription().substring(0,10) ); %>
																								</td>
																						</tr>
																						<tr>
																							<td colspan="3" class="links2" align="center" height="21" valign="bottom">Price:
																								<span class="redtext"><%=pdt.getCurrentPrice() %></span>																							</td>
																						</tr>
																						<tr>
												 											<td align="center"><a href="<%=contextPath %>/web/productDetail.action?product.id=<%=pdt.getId() %>" class="readmore">View Item</a>&nbsp;<img src="images/arrow_blue.gif" height="5" width="5"></td>
											  											</tr>
																					</table>																				</td>
									  										</tr>
																		</table>																	
																	</td>
							     									<td>
							     										<img src="images/line-hor.gif" height="150" width="22">							     									
							     									</td>
							     									<%
							     									pdt = new Product();
																	pdt.setDescription("");
																	pdt.setCurrentPrice(0.0);
																	if ( (k+1)< products.size() ){
																		pdt = products.get(k+1);
																	%>
					  												<td height="100%" valign="top" width="49%">
					   													<table border="0" cellpadding="3" cellspacing="1" height="100%" width="100%">
							  												<tr>
							  												 <%
																					 image = new ImageMapBean();
																					 image.setReferenceId(pdt.getId());
																					 images =imagesService.getImagesByReferenceId(image);
																					 image = (images.size()==0?null:images.get(0));
										 										%>
																				<td align="center"><img src="<%=contextPath %>/<%if ( image != null ) out.println( image.getImageUrl()); %>"  alt=""  height="90"  width="120"></td>
							  												</tr>
							  												<tr>
																				<td valign="bottom">
																					<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
																						<tr>
																							<td colspan="3" class="headers" align="center" height="30" valign="top">
																								<% if ( pdt.getDescription().length()>10) out.println( pdt.getDescription().substring(0,10) ); %>
																							</td>
																						</tr>
																						<tr>
																							<td colspan="3" class="links2" align="center" height="21" valign="bottom">Price:
																								<span class="redtext">$
																								<% if ( pdt.getCurrentPrice() != 0)  out.println( pdt.getCurrentPrice() ); %>
																								</span>																							</td>
																						</tr>
																						<tr>
																						 	<td align="center"><a href="<%=contextPath %>/web/productDetail.action?product.id=<%=pdt.getId() %>" class="readmore">View Item</a>&nbsp;<img src="images/arrow_blue.gif" height="5" width="5"></td>
																						  </tr>
																					</table>																				</td>
							  												</tr>
																		</table>																	
																	</td>
																	<%} %>
												     		  </tr>
												     		  <%} %>
							 								<!-- product list end -->
							 								<tr></tr>
							 								<!-- 
														 	<tr>
																<td colspan="3" align="right">
																	&nbsp;<a href="<%=contextPath %>/web/Anklet-Jewelry-Bead-Online.action?page=2" class="readmore">next &gt;&gt;</a>					
																</td>
															</tr>
															-->  
													</table>
												</td>
											</tr>   
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</td></tr>
<tr>
<td height="5"></td>
</tr>
			 <%-- --%>
  <%@ include file="bottom.jsp"%>
		</table>
	
</body></html>